package com.yiren.manager.ctrl;

import org.springframework.beans.factory.annotation.Autowired;

import com.yiren.core.exception.MyException;
import com.yiren.core.utils.MyMessage;
import com.yiren.manager.service.iface.elder.YrElderBeHospitalService;

/**
 * controller基类
 */
public abstract class GenericController <F, T>{
	
	@Autowired
	private YrElderBeHospitalService elderBeHospitalService;
	
	/**
	 * 转换为表单
	 * @param 
	 * @return
	 */
	public abstract F toForm (T e) throws Exception;
	
	/**
	 * 
	 * @param e
	 * @return
	 */
	public abstract T toEntity(F f) throws Exception;
	
	/**
	 * 抛出异常
	 * @param info
	 * @throws MyException
	 */
	public void throwExp(String info) throws MyException{
		MyException ex = new MyException(new MyMessage(info));
		ex.messages.addError(ex);
		throw ex;
	}
	
}
